{{template "shared/bootstrap_table_js.html"}}
<script>
    var $dataGrid = $('#dataGrid');
    var $searchForm = $('#searchForm');
    
    var highlightPk = 0;
    
    $(function () {
        pageInit()
    });
    
    function pageInit() {
        dataGridInit()
    }
    
    function dataGridInit() {
        $dataGrid.bootstrapTable({
            url: '{{urlfor "WeChatController.DataGrid"}}',
            method: 'post',
            sidePagination: 'server',
            idField: 'Id',
            queryParamsType: 'limit',
            queryParams: function (params) {
                params.Title = $.trim($('.searchForm input[name="Title"]').val());
                return params
            },
            pagination: true,
            showRefresh: true,
            showColumns: true,
            toolbar: '#toolbar',
            pageSize: 10,
            pageList: [5, 10, 20, 100, 200],
            paginationShowPageGo: true,//20170812 lht 扩展select跳转
            paginationUseBSSelect: true,//20170812 lht 扩展select跳转 启用BoostrapSelect(页面须引用botstrap-select.min.js)
            cookie: true,
            classes: 'table table-bordered table-hover',
            undefinedText: '',
            sortName: 'Id',
            sortOrder: 'desc',
            stickyHeader: true,
            resizable: true,

            rowAttributes: function (row, index) {
                return {'data-pk': row.Id}
            },
            columns: [{
                field: 'state',
                checkbox: true,
                radio: false
            }, {
                field: 'Id',
                title: 'ID',
                width: '80px',
                align: 'center',
                sortable: true
            }, {
                field: 'Nickname',
                title: '昵称',
                align: 'center'
            }, {
                field: 'Platform',
                title: '平台',
                align: 'center'
            }, {
                field: 'Gender',
                title: '性别',
                align: 'center'
            }, {
                field: 'Province',
                title: '省',
                align: 'center'
            }, {
                field: 'City',
                title: '市',
                align: 'center'
            }, {
                field: 'Country',
                title: 'Country',
                align: 'center'
            }],
            onLoadSuccess: function (data) {
                layer.closeAll('loading')
            },
            onSort: function (name, order) {

            },
            onCheckAll: function (rows) {
                $(".table-btn-check-enable").removeAttr("disabled")
            },
            onCheck: function (rows) {
                $(".table-btn-check-enable").removeAttr('disabled');
            },
            onUncheck: function (rows) {
                if ($("#dataGrid").bootstrapTable("getSelections").length === 0) {
                    $(".table-btn-check-enable").attr('disabled', 'disabled');
                }
            },
            onUncheckAll: function () {
                //禁用删除需要勾选才能用的按钮
                if ($("#dataGrid").bootstrapTable("getSelections").length === 0) {
                    $(".table-btn-check-enable").attr('disabled', 'disabled');
                }
            },
            onLoadError: function (status) {
                layer.alert('获取数据失败,错误代码：' + status);
            }
        });
    }
</script>